﻿using System.Windows.Forms;
using GalaSoft.MvvmLight.Messaging;
using Marc.JwOrgClient.Messages;

namespace Marc.JwOrgClient {
    public partial class MainWindow {
        public MainWindow() {
            InitializeComponent();
            Messenger.Default.Register<ShowFolderBrowserDialogMessage>(this,
                                                                       msg => {
                                                                           var dlg = new FolderBrowserDialog {SelectedPath = msg.InitialFolder, ShowNewFolderButton = true};
                                                                           DialogResult result = dlg.ShowDialog(null);
                                                                           if (result == System.Windows.Forms.DialogResult.OK) {
                                                                               msg.FolderSelectedCallback(dlg.SelectedPath);
                                                                           }
                                                                       });
        }
    }
}